import sys

from .moops_web import run as run_
from ..libmoops import config

def run():

    host = config.get('web_ui', 'host')
    port = config.get('web_ui', 'port')

    if config.getboolean('global','debug') and not hasattr(sys, 'frozen'):
        #this is an ugly, ugly hack.
        sys.argv = ['-c', 'import moops; moops.run_web()']

        run_(reloader=True, host=host, port=port)
    else:
        run_(host=host, port=port)
